home *** CD-ROM | disk | FTP | other *** search
-
-
- {$line+,$symtab-,$linesize:131,$pagesize:65}
- program SIDEPC(input,output,infile);
-
- {This program will print the `infile' sideways on an Oki PCWRITER Printer.
- As the PCWRITER uses the IBM Graphics Instruction set, this pgm should
- run unmodified on the IBM Graphics printer. By looking at the entries
- in the const. tables, modifications for other printers can be made.
- It makes use of the characters in the PC's ROM for the graphics mode of
- the CRT. The characters in the file are `looked up' and then the graphics
- mode of the printer is used for output.}
-
- { The DEBUG statements will output on the CRT the current line being printed.
- The line will appear vertically. }
-
- type
- vstr = super array[0..*] of char;
- CHAR_PER_LINE = 0..2000; {Maximum input line size}
- FNAME = packed array[1..15] of char;
- PSIZER = 1..2;
- const
- EOF = chr(26); {TEXT EOF character}
- EOL = chr(13);
- TAB = chr(9); {expand TABs}
- IGNORE = [chr(0)..chr(8),chr(10)..chr(#1f),chr(#80)..chr(#FF)];
- MAX_LINES = 48*2; {Lines/Page}
- SPACES_PER_LINE = 2; {2/72th inch space between lines}
- SPACES_PER_LETTER = 8; {DOT size of characters}
- { PCWRITER ADDITIONS - TO SHIFT GRAPHICS MODES }
- FEED = chr(27)*chr(65); { ESCape A (sel. var. space) }
- FEEDSET = CHR(27)*CHR(50); { ESCape 2 (use Esc A set spacing)}
- L3 = chr(27); { ESCAPE }
- L1 = chr(76); { 'L' for 120 dpi graphics}
- L2 = chr(75); { 'K' for 60 dpi graphics}
- W = chr(8); { Large Char Linefeed spacing }
- N = chr(7); { Small Char Linefeed spacing }
- var
- psize : PSIZER;
- lptr : array[1..MAX_LINES] of ^vstr; {input lines}
- inbuf : array[CHAR_PER_LINE] of char;
- linesize : CHAR_PER_LINE;
- linemax : integer;
- indx : 0..MAX_LINES;
- line : 0..MAX_LINES+1;
- infile : file of char;
- printer : text;
- col : CHAR_PER_LINE;
- pchar : integer;
- ichar : 0..7;
- max : CHAR_PER_LINE;
- rom : ads of array[0..32000] of char;
- prints : FNAME;
- GRAPHMODE : char;
- GRAPHFEED : char;
- scroll : integer;
-
- value
- {NOTE!!!!
- The following declarations define the segment and offset values
- for the characters in the PC version of the ROM. For the XT, check
- the TECH MANUAL for the correct values.}
-
- rom.s := #F000; {address of the CRT character generation}
- rom.r := #FA6E; {matrix in the ROM -- for non-XT versions of PC}
-
- begin
- for scroll := 1 to 11 do writeln(output);
- writeln(output,'Enter name of file to write, [RETURN] for printer');
- for scroll := 1 to 11 do writeln(output);
- readln(prints);
- if prints = ' ' then prints :='lpt1: ' else prints := prints;
-
- for scroll := 1 to 11 do writeln(output);
- writeln(output,'Select [1] Normal or [2] Compressed printing');
- for scroll := 1 to 11 do writeln(output);
- readln(psize);
- if (psize = 1) then begin
- GRAPHMODE := L2;
- GRAPHFEED := W;
- linemax := (MAX_LINES div 2);
- end
- else begin
- GRAPHMODE := L1;
- GRAPHFEED := N;
- linemax := (MAX_LINES);
- end;
- assign(printer,prints); {open output file or the printer}
- rewrite(printer);
- reset(infile);
- repeat
- max := 0;
- linesize := 0;
- line := 1;
- while (line <= linemax) do begin
- if infile^ = EOL then begin {check for End-of-Line}
- new(lptr[line],linesize+1); {allocate string storage}
- movel(adr inbuf[0],adr lptr[line]^[0],wrd(linesize+1)); {save}
- if linesize > max then max := linesize;
- linesize := 0;
- line := line+1;
- get(infile);
- writeln(output,'<<'); {--DEBUG--}
- cycle;
- end;
- if infile^ = EOF then break;
- if not(infile^ in IGNORE) then begin
- if infile^ = TAB then
- repeat {Expand TABs}
- linesize := linesize+1;
- inbuf[linesize] := ' ';
- until (linesize mod 8) = 0
- else begin
- linesize := linesize+1;
- inbuf[linesize] := infile^;
- end;
- write(output,infile^); {--DEBUG--}
- end;
- get(infile);
- end;
- writeln(output,'line=',line,' max=',max); {--DEBUG--}
- if infile^ <> EOF then line := linemax
- else line := line-1;
- for col := 1 to max do begin {Output collected lines}
- write(printer,FEED,GRAPHFEED,FEEDSET,L3,GRAPHMODE,
- chr((line*(8+SPACES_PER_LINE)) mod 256),
- chr((line*(8+SPACES_PER_LINE)) div 256));
- for indx := line downto 1 do begin {Scan next column}
- {if column pointer is larger than string, output BLANK}
- if col > (upper(lptr[indx]^)-1) then pchar := ord(' ')
- else pchar := ord(lptr[indx]^[col]);
- write(output,chr(pchar)); {--DEBUG--}
- pchar := pchar*8;
- for ichar := 7 downto 0 do {Pickup character, a line at a time, }
- write(printer,rom^[pchar+ichar]); {from ROM}
- for ichar := 1 to SPACES_PER_LINE do write(printer,chr(0));
- end;
- writeln(printer);
- writeln(output); {--DEBUG--}
- end;
- for indx := 1 to line do dispose(lptr[indx]); {Free up space on HEAP}
- page(printer);
- until infile^ = EOF;
- if (prints <> 'lpt1: ' ) then page(printer); {final eject; when using a file for output, will allow
- a [ copy <filename> prn ] instruction where <filename>
- is a wildcard.}
- end.
-